<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="content">
	<div class="post">
		<!-- 日期-标题 -->
		<div class="date"><span>${post.date.year }</span><span class="f">${post.date.zhMonth }${post.date.day }</span></div>
		<h2><a href="" rel="bookmark">${post.title }</a></h2>
		
		<!-- 信息 -->
		<div class="info">
			<span class="categories"><a href="" title="查看${post.category.name }的全部文章" rel="category">${post.category.name }</a></span>
       		<span class="tags">${post.tags }</span>
       		<c:if test="${user != null}">
       		<a class="post-edit-link" href="AdminServlet?action=editPost&id=${post.id }" title="编辑文章">编辑</a>&raquo; 
       		<a class="post-edit-link" href="AdminServlet?action=deletePost&id=${post.id }" title="编辑文章">删除</a>&raquo; 
       		</c:if>
			<span class="comments"><a href="" class="Comments off"  title="${post.title }上的评论"><em>${post.commentCount }</em> Comments</a></span>
		<div class="clear"></div>
		</div>
			
		<!-- 文章内容 -->
		<div class="intro">
			<p>${post.content}</p>
		</div>
		
		<!-- 作者声明 -->
		<div class="under">
			<p>文章作者：<a href="http://javafans.info">Talin</a><br />版权所有 &copy; 转载时必须以链接形式注明作者和原始出处！</p>
		</div>
		
	</div><!-- Post -->
	
      <!-- 评论 -->
      <div class="comment_box">
      	<h3 id="comments">
      		${post.commentCount }条相关评论
		</h3>
		<!-- 评论列表 -->
		<c:forEach items="${commentList}" var="comment">
		<ol class="commentlist">
			<li id="comment-${comment.id }" class="comment">
				<div class="cheader regularheader">
					<img alt='' src='images/headpic.gif' class='avatar avatar-32 photo' height='32' width='32' />
						<div class="item">
							<span class="lou"><a href="#comment-${comment.id }">#${comment.id }</a>
							</span>
							
							<span class="cauthor with_avatar"> 
								<span title="${comment.author }"> ${comment.author } </span> 
							</span> 
							
							<span class="items">
							<c:if test="${user != null}">
								<a class="comment-edit-link" href="" title="编辑评论">编辑</a> 
								<a class="comment-edit-link" href="" >删除</a>
							</c:if>
							</span> 
							
							<span class="cdate"> Post:${comment.date.fmtDateTime }
							</span>
						<div class="clear"></div>
						</div>
				</div>
				
				<div class="cbody">
				<p>${comment.content }</p>
				</div>
				
			<div class="clear"></div>
			</li>
		</ol><!-- 评论列表 -->
		</c:forEach>
		
		
		<div id="respond">
			<form id="commentform" name="commentform" action="CommentServlet?action=add" method="post">
				<h3>发表评论</h3>
				<div class="form_box">
					<div class="text">
						<textarea name="content" class="textarea" cols="64" rows="8"></textarea>
					</div>
					
					<div class="form_info">
						<div class="part">
						<c:if test="${user!=null}">
							<div class="row">登录帐号: <a href="pageAbout.jsp"><strong>${user.nickname }</strong></a>.
								<a href="AdminServlet?action=logout" title="退出登录">登出 &raquo;</a>
								<input type="hidden" name="author" value="${user.nickname }"/>
								<input type="hidden" name="email" value="${user.email }"/>
							</div>
						</c:if>
						<c:if test="${user==null}">
							<div id="author_info">
								<div><label for="author" class="small">昵称 </label></div>
								<div><input type="text" class="textfield" name="author" /></div>
								<div><label for="email" class="small">E-Mail  (will not be published)</label></div>
								<div><input type="text" class="textfield" name="email"/></div>
							</div>
						</c:if>
						</div>
						<div class="part">
							<input type="hidden" name="postId" value="${post.id }"/>
							<input type="submit" id="submit" class="button" tabindex="5" value="提交评论" /> 
						</div>
					</div>

					<div class="clear"></div>
				</div>
			</form>
      </div>
</div>
</div>